package com.yaozheng.vocationaltraining.view.dialog;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.yaozheng.vocationaltraining.R;
import com.yaozheng.vocationaltraining.dialog.interfaces.BaseDialogEventProcess;

import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EViewGroup;
import org.androidannotations.annotations.ViewById;

/**
 * 删除询问对话框view
 */
@EViewGroup(R.layout.view_dialog_confirm_cancel_ask)
public class ConfirmCancelAskDialogView extends LinearLayout {
    BaseDialogEventProcess baseDialogEventProcess;

    @ViewById
    TextView baseDialogOperateExplanationId, baseDialogContentTextView, baseDialogDetermineView,
            baseDialogCancelView;

    public ConfirmCancelAskDialogView(Context context) {
        super(context);
    }

    public ConfirmCancelAskDialogView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    /**
     * 设置按钮值
     *
     * @param buttonValue1
     * @param buttonValue2
     */
    public void setButtonValue(String buttonValue1, String buttonValue2) {
        baseDialogCancelView.setText(buttonValue1);
        baseDialogDetermineView.setText(buttonValue2);
    }

    /**
     * 设置数据响应
     *
     * @param baseDialogEventProcess
     */
    public void setBaseDialogEventProcess(BaseDialogEventProcess baseDialogEventProcess) {
        this.baseDialogEventProcess = baseDialogEventProcess;
    }

    /**
     * 设置标题并且内容
     *
     * @param title
     * @param content
     */
    public void setTitleAndroidContent(String title, String content) {
        if (title == null) {
            baseDialogOperateExplanationId.setVisibility(View.GONE);
        } else {
            baseDialogOperateExplanationId.setVisibility(View.VISIBLE);
            baseDialogOperateExplanationId.setText(title);
        }
        baseDialogContentTextView.setText(content);
    }

    @Click({R.id.baseDialogCancelView, R.id.baseDialogDetermineView})
    public void executeTagClick(View view) {
        if (baseDialogEventProcess != null) {
            baseDialogEventProcess.runMethod(String.valueOf(view.getTag()));
        }
    }
}
